using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using Liberty.Application.CaseManagement;
using Liberty.Domain.CaseManagement;
using Liberty.Domain.Kernel;
using Peradigm.Framework.Domain.Parties;
using Peradigm.Framework.Domain.Security;

using Microsoft.VisualStudio.TestTools.UnitTesting;
//using NUnit.Framework.SyntaxHelpers;

using Rhino.Mocks;

namespace Tests.ApplicationTests.CaseManagement
{
#if DEBUG
    [TestClass()]
    
    public class CaseControllerTests : Object
    {
        #region Constants
        #endregion

        #region SetUp and TearDown CaseControllerTests
        [TestInitialize()]
        public void SetUpCaseControllerTests()
        {
        }

        [TestCleanup()]
        public void TearDownCaseControllerTests()
        {
        }
        #endregion

        #region Test Methods


        [TestMethod()]
        public void TestCaseWith()
        {
            CaseController caseController = new CaseController();
            Case aCase = caseController.CaseWith( 1 );
            Assert.AreEqual( 1, aCase.Oid );
        }	
            
	    [TestMethod()]
	    public void TestCasesFor()
	    {
            // Create a "mock repository."  This will keep track of all of the mocking to be recorded and verified.
            MockRepository mocks = new MockRepository();

            // Create a list of fake cases that we want to have our mock broker return, so that we can test our controller
            // in isolation.  Testing of the actual broker will of course be done in its own test fixture.
            List<Case> aCaseList = new List<Case>();
            aCaseList.Add( new Case() );

            User user = new User();

            // Create a mock case broker.  This object will mock the real case broker and return what we tell it to
            // return, namely a list of cases when sent the message casesFor( user ).
            //CaseBroker mockedBroker = mocks.DynamicMock<CaseBroker>( String.Empty );

            // Give our caseController, the unit we are actually testing here, the mocking case broker.
            CaseController caseController = new CaseController();
            //caseController.CaseBroker = mockedBroker;

            // Tell the mock repository to expect that the message casesFor(..) will be sent to the mocked cases broker,
            // to ignore the arguments sent to the mocked broker, and to always return our fake case list when
            // this message is sent.
            //Expect.On( mockedBroker ).Call( mockedBroker.CasesFor( user ) ).IgnoreArguments().Return( aCaseList );

            // Tell the mock repository to get ready to replay what was "recorded" above when the mocks are accessed.
            // Initializes mocked object.
            mocks.ReplayAll();

            //Assert.That( caseController.CasesFor( user ), Is.EqualTo( aCaseList ) );

            // Tell the mock repository o verify that all object interactions
            // happened as recorded/expected.  If they do not, the unit test will fail.
            mocks.VerifyAll();
	    }
	           
	    [TestMethod()]
	    public void TestTasksFor()
	    {
            // Create a "mock repository."  This will keep track of all of the mocking to be recorded and verified.
            MockRepository mocks = new MockRepository();

            // Create a list of fake tasks that we want to have our mock broker return, so that we can test our controller
            // in isolation.  Testing of the actual broker will of course be done in its own test fixture.
            List<Task> aTaskList = new List<Task>();
            aTaskList.Add( new Task() );

            User user = new User();

            // Create a mock task broker.  This object will mock the real task broker and return what we tell it to
            // return, namely a list of tasks when sent the message tasksFor( criteria ).
            //CaseBroker mockedBroker = mocks.DynamicMock<CaseBroker>( String.Empty );

            // Give our caseController, the unit we are actually testing here, the mocking task broker.
            CaseController caseController = new CaseController();
            //caseController.TaskBroker = mockedBroker;

            // Tell the mock repository to expect that the message tasksFor(..) will be sent to the mocked task broker,
            // to ignore the arguments sent to the mocked broker, and to always return our fake tasks list when
            // this message is sent.
            //Expect.On( mockedBroker ).Call( mockedBroker.TasksFor( user ) ).IgnoreArguments().Return( aTaskList );

            // Tell the mock repository to get ready to replay what was "recorded" above when the mocks are accessed.
            // Initializes mocked object.
            mocks.ReplayAll();

            //Assert.That( caseController.TasksFor( user ), Is.EqualTo( aTaskList ) );

            // Tell the mock repository to verify that all object interactions
            // happened as recorded/expected.  If they do not, the unit test will fail.
            mocks.VerifyAll();
        }

        [TestMethod()]
        public void TestAllFacilities()
        {
            CaseController caseController = new CaseController();
           List<Facility> facilities =  caseController.AllFacilities();

           foreach( Facility facility in facilities )
           {
               if( facility.Code == "BAMC" )
                   Assert.AreEqual( facility.Name, "Brook Army Medical Center" );
           }
          
        }	
        
        #endregion

        #region Support Methods
        #endregion

        #region Data Elements
        #endregion
        
    }
#endif
	
}
